class TalkDialog extends renderer.DisplayObjectContainer {


    private titleText: renderer.TextField;
    private contentText: renderer.TextField;
    private mission: Mission;

    constructor() {
        super();

        const dialogBackgroundTexture = new Image();
        dialogBackgroundTexture.src = 'dialog.png';

        const background = new renderer.Bitmap(0, 0, dialogBackgroundTexture);
        // background.scaleX = background.scaleY = .5;
        this.addChild(background);
        const textField = new renderer.TextField();
        this.addChild(textField);
        textField.text = "把他当成是一个弹窗";
        textField.x = 250;
        textField.y = 20;

        this.titleText = new renderer.TextField();
        this.addChild(this.titleText);
        this.titleText.x = this.titleText.y = 100;

        this.contentText = new renderer.TextField();
        this.addChild(this.contentText);
        this.contentText.x = 100;
        this.contentText.y = 130;
        this.addEventListener("click", () => {
            this.dispatchEvent('close', {});
        });

    }

    update() {
        const mission = this.mission;
        let content = ""

        this.titleText.text = mission.title;
        if (mission.status == MissionStatus.CAN_ACCEPT) {
            content = mission.canAcceptContent

        }
        else if (mission.status == MissionStatus.CAN_SUBMIT) {
            content = mission.canSubmitContent

        }

        this.contentText.text = content;
    }

    setMission(mission: Mission) {
        this.mission = mission;
        this.update();
    }



}